package com.lh.glorypavilion.service.cms.controller.api;

import com.lh.glorypavilion.result.R;
import com.lh.glorypavilion.service.cms.entity.Ad;
import com.lh.glorypavilion.service.cms.service.IAdService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

//@CrossOrigin //解决跨域问题
@Api(description = "广告推荐")
@RestController
@RequestMapping("/api/cms/ad")
@Slf4j
public class ApiAdController {

    @Autowired
    private IAdService adService;

    @ApiOperation("根据推荐位id显示广告位推荐")
    @GetMapping("list/{adTypeId}")
    public R getListAdByAdTypeId(@ApiParam(value = "推荐位id",required = true) @PathVariable("adTypeId") String adTypeId){
        List<Ad> adList=adService.selectByAdTypeId(adTypeId);
        return R.ok().data("items",adList);
    }

}
